package com.ydsungan.daoimpl;

import com.ydsungan.bean.Signin;
import com.ydsungan.dao.SigninDao;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

public class SigninDaoImpl implements SigninDao {

    SqlSessionFactory sqlSessionFactory = null;
    public SigninDaoImpl(SqlSessionFactory sqlSessionFactory) {
        this.sqlSessionFactory = sqlSessionFactory;

    }
    @Override
    public List<Signin> getSigninByMap(Map<String, Object> map) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        List<Signin> list = sqlSession.selectList("getSigninByMap", map);
        sqlSession.close();
        return list;
    }

    @Override
    public void addSignin(Signin signin) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        sqlSession.insert("addSignin", signin);
        sqlSession.commit();
        sqlSession.close();
    }

    @Override
    public void deleteById(Integer id) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        sqlSession.delete("deleteById", id);
        sqlSession.commit();
        sqlSession.close();
    }
}
